package basis.第十四章;


import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.*;

class MyPriority implements Runnable {
    private int countdown = 5;
    private int priority;

    public MyPriority(int priority) {
        this.priority = priority;
    }

    @Override
    public String toString() {
        return Thread.currentThread() + ":" + countdown+"---"+priority;
    }

    @Override
    public void run() {
        Thread.currentThread().setPriority(priority);
        while (true) {


            System.out.println(this);
            if (--countdown == 0) return;
        }
    }
}

public class Example2126 {
    public static void main(String[] args) {
        Executor executor = Executors.newCachedThreadPool();

        for (int i = 0; i < 5; i++) {
            executor.execute(new MyPriority(Thread.MIN_PRIORITY));
        }
        executor.execute(new MyPriority(Thread.MAX_PRIORITY));


    }
}
